package File;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2022-04-04
 * Time: 13:33
 */
public class Demo9 {
    public static void main(String[] args) {
        try (InputStream is = new FileInputStream("hello-world")){
            byte[] buffer = new byte[1024];
            int len;
            while(true) {
                len = is.read(buffer);
                if(len == -1) {
                    break;
                }
                for (int i = 0; i < len; i += 3) {
                    String s = new String(buffer, i, 3, "UTF-8");
                    System.out.printf("%s", s);
                }
            }
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
}
